{include file="public/layout" /}
<body>
  <link rel="stylesheet" href="__SKIN__/css/page.css" media="all">
  <div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-row">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="web-system">
            <div class="layui-tab layui-tab-card">
              <ul class="layui-tab-title">
                  <li><a href="{:url('form/index')}">报名信息管理</a></li>
                  <li class="layui-this"><a href="{:url('Form/attr_index')}">报名表单管理</a></li>
                  <li><a href="{:url('Form/config')}">报名提醒管理</a></li>
              </ul>
              <div class="layui-tab-content" style="padding:10px 0">
                <div class="layui-tab-item layui-show">
                  <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                      <div class="layui-card">
                        <div class="head-oper">
							<div class="baoming-cate fl">
							  <ul>
                                  {volist name="channel_list" id="vo"}
                                  <li><a {eq name="$Request.param.channel_id" value="$vo.id"}class="cur"{/eq} href="{:url('Form/attr_index',['channel_id'=>$vo['id']])}">{$vo.ntitle}</a></li>
                                  {/volist}


							  </ul>
							</div>
                            <div class="fr">
                                {notempty name='$form_id'}
                                <a href="{:url('Form/index')}" class="layui-btn layui-btn-primary  input-btn-back"><i class="layui-icon layui-icon-left"></i></a>
                                {/notempty}
                                {eq name="$Think.const.CONTROLLER_NAME.'@add'|is_check_access" value="1"}
                                <a data-url="{:url('Form/add')}" data-type="Form_add" class="layui-btn mt5 ">新增表单</a>
                                {/eq}
                            </div>
                        </div>
                        <div class="layui-card-body" pad15>
                            <div class="layui-form layui-border-box layui-table-view house-table" lay-filter="demo" lay-id="admin-arctype" >
                                <div class="layui-table-box">
                                    <div class="layui-table-body " >
                                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-form" style="width: 100%" lay-skin="line">
                                            <thead >
                                            <tr>
                                                <th class="w40 tc"> <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                                    <input type="checkbox" lay-filter="checkAll" id="checkAll" lay-skin="primary" >
                                                </th>
                                                <th class="w60 tc"> <div class="layui-table-cell w60 tc" ><span>ID</span></div></th>
                                                <th class="wauto"> <div class="layui-table-cell wauto"><span>表单名称</span></div></th>
                                                <th class="w100 tc"> <div class="layui-table-cell w200 tc"><span>所属模型</span></div></th>
                                                <th class="w100 tc"> <div class="layui-table-cell w100 tc"><span>报名数量</span></div></th>
                                                <th class="w100 tc"> <div class="layui-table-cell w100 tc"><span>字段数量</span></div></th>
                                                <th class="w300 tc"> <div class="layui-table-cell w300 tc"><span>操作</span></div></th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                              {empty name="list"}
                                                <tr>
                                                  <td colspan="6" class="no-data tc">
                                                     没有符合条件的数据
                                                  </td>
                                                </tr>
                                              {else/}
                                                {foreach name="list" item="vo" key="k" }
                                                <tr>
                                                    <td>
                                                        <div class="layui-table-cell w40 tc laytable-cell-checkbox">
                                                            <input type="checkbox" name="form_ids[]" value="{$vo.id}" lay-filter="form_ids" lay-skin="primary">
                                                        </div>
                                                    </td>
                                                    <td><div class="layui-table-cell w60 tc"> {$vo.id} </div></td>
                                                    <td><div class="layui-table-cell wauto"><a href="javascript:void(0);" data-url="{:url('Form/index',['form_id'=>$vo['id']])}" class="eju-event" data-type="Form_edit">{$vo.name}</a></div></td>
                                                    <td>
                                                        <div class="layui-table-cell w200 tc">
                                                            {$vo.channel_name}
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="layui-table-cell w100 tc">
                                                            <a href="javascript:void(0);" data-url="{:url('Form/index',['form_id'=>$vo['id'],'tabase'=>1])}" class="eju-event blue" data-type="Form_index">{$form_list_total[$vo['id']]['total']|default='0'}</a>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="layui-table-cell w100 tc">
                                                            <a href="javascript:void(0);" data-url="{:url('Form/edit',array('form_id'=>$vo['id']))}" class="eju-event blue" data-type="Form_edit">{$form_attr_total[$vo['id']]['total']|default='0'}</a>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div class="layui-table-cell w300 tc layadmin-layer-demo right-oper">
                                                            {eq name="$Think.const.CONTROLLER_NAME.'@edit'|is_check_access" value="1"}
                                                            <a class="layui-btn btn-edit customvar_edit" data-url="{:url('Form/edit',array('form_id'=>$vo['id']))}" data-type="Form_edit">
                                                            编辑
                                                            </a>
                                                            {/eq}
                                                            <a class="layui-btn btn-primary" data-url="{:url('Form/label_call',array('form_id'=>$vo['id']))}" data-type="lable_call">
                                                                标签调用
                                                            </a>
                                                            {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                                            <a class="layui-btn btn-primary" data-url="{:url('Form/form_del')}" data-id="{$vo.id}" data-type="Form_del" >
																删除
                                                            </a>
                                                            {/eq}
                                                        </div>
                                                    </td>
                                                </tr>
                                                {/foreach}
                                            {/empty}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="layui-table-page">
                                    <a class="layui-btn layui-btn-xs" data-type="textAll" id="textAll" data-value="0">全选</a>
                                    {eq name="$Think.const.CONTROLLER_NAME.'@form_del'|is_check_access" value="1"}
                                    <a class="layui-btn layui-btn-danger layui-btn-xs " data-type="batch_del" data-url="{:url('Form/form_del')}">
                                    <i class="layui-icon layui-icon-delete"></i>批量删除
                                    </a>
                                    {/eq}
                                </div>
                                <!--分页-->

                            </div>
                            {$pageStr}
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

    <script>
        layui.config({
        base: '__SKIN__/' //静态资源所在路径
        ,version: '{$version}'
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function(){
            var $ = layui.$
                ,element = layui.element
                ,layer = layui.layer
                ,form = layui.form;

            element.render();

            /* 触发事件 */
            var active = {
                textAll: function(){
                    var value = $(this).attr('data-value');
                    if (0 == value) {
                        $(this).attr('data-value', 1).html('取消');
                        $('#checkAll').attr('checked', true);
                        $('input[name*=form_ids]').attr('checked', true);
                    } else {
                        $(this).attr('data-value', 0).html('全选');
                        $('#checkAll').attr('checked', false);
                        $('input[name*=form_ids]').attr('checked', false);
                    }
                    form.render('checkbox');
                }
                ,Form_index: function(){
                    var iframes = layer.open({
                        type: 2,
                        title: '报名内容管理',
                        fixed: true, //不固定
                        shadeClose: false,
                        shade: 0.3,
                        content: $(this).data('url')
                    });
                    layer.full(iframes);
                }
                ,Form_add: function(){
                    var iframes = layer.open({
                        type: 2,
                        title: '新增表单',
                        fixed: true, //不固定
                        shadeClose: false,
                        shade: 0.3,
                        content: $(this).data('url')
                    });
                    layer.full(iframes);
                }
                ,lable_call:function () {
                    layer.open({
                        type: 2,
                        title: '代码调用', shadeClose: true,
                        area: ['90%', '90%'],
                        content: $(this).data('url')
                    });
                }
                ,Form_edit: function(){
                    var iframes = layer.open({
                        type: 2,
                        title: '编辑表单',
                        fixed: true, //不固定
                        shadeClose: false,
                        shade: 0.3,
                        content: $(this).data('url')
                    });
                    layer.full(iframes);
                }
                ,Form_del: function(){
                    delfun(this);
                }
                // 批量删除
                ,batch_del: function(){
                    batch_del(this,'form_ids');
                }
            };
            $('#LAY-component-layer-list .layui-btn,.eju-event').on('click', function(){
                var type = $(this).data('type');
                active[type] && active[type].call(this);
            });

            // 监听复选框全选
            form.on('checkbox(checkAll)', function(data){
                if (data.elem.checked) {
                    $('input[name*=form_ids]').attr('checked', true);
                    $('#textAll').attr('data-value', 1).html('取消');
                } else {
                    $('input[name*=form_ids]').attr('checked', false);
                    $('#textAll').attr('data-value', 0).html('全选');
                }
                form.render('checkbox');
            });

            // 监听每行复选框
            form.on('checkbox(form_ids)', function(data){
                if (data.elem.checked && $('input[name*=form_ids]:checked').length == $('input[name*=form_ids]').length) {
                    $('#checkAll').attr('checked', true);
                    $('#textAll').attr('data-value', 1).html('取消');
                } else {
                    $('#checkAll').attr('checked', false);
                    $('#textAll').attr('data-value', 0).html('全选');
                }
                form.render('checkbox');
            });

            //开启以读
            form.on('switch(is_read)', function(obj){
                var dataid = $(this).attr('data-id');
                if ($(this).val() == 1){
                    $(this).val(0);
                }else{
                    $(this).val(1);
                }
                changeTableVal('form_list','list_id',dataid,'is_read',this);
            });
        });
    </script>

    {include file="public/footer" /}